package com.example.java_gobang.model;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;//状态码
    private String errMsg;//错误信息
    private T data;//数据
    public static <T> Result<T> success(T data){
        Result result = new Result();
        result.setCode(200);
        result.setErrMsg("");
        result.setData(data);
        return result;
    }
    public static<T> Result<T> fail(String msg){
        Result result = new Result();
        result.setCode(500);
        result.setErrMsg(msg);
        return result;
    }
    public static<T> Result<T> fail(String msg,T data){
        Result result = new Result();
        result.setCode(500);
        result.setErrMsg(msg);
        result.setData(data);
        return result;
    }
    public static<T> Result<T> unLogin(String msg){
        Result result = new Result();
        result.setCode(403);
        result.setErrMsg(msg);
        return result;
    }
}
